Skip to content

[Woo POS] Update conditions for showing POS entry point #11513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

samiuelson
Copy link
Contributor

@samiuelson samiuelson commented May 14, 2024

Closes: #11498

Description

This PR updates the conditions for showing the POS entry point:

  1. tablet device
  2. USD currency
  3. US store location
  4. Woo Payments plugin enabled and user setup complete
  5. Feature Flag enabled

Testing instructions

Ensure the POS entry point button (in the menu more screen) is visible if the above conditions are met and invisible otherwise.

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@samiuelson samiuelson marked this pull request as ready for review May 14, 2024 15:04
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 14, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
FlavorJalapeno
Build TypeDebug
Commit535d184
Direct Downloadwoocommerce-prototype-build-pr11513-535d184.apk

@backwardstruck backwardstruck self-assigned this May 14, 2024
@backwardstruck
Copy link
Contributor

Tested on tablet, phone and split screen:

Screenshot_20240514_144333 ```html Screenshot_20240514_144225 ```html Screenshot_20240514_143646

Copy link
Contributor

@backwardstruck backwardstruck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a flaky test on CI.

@samiuelson samiuelson enabled auto-merge May 15, 2024 07:18
…if-pos-mode-available-show-entry-point-only-if-it-allows-it
@dangermattic
Copy link
Collaborator

dangermattic commented May 15, 2024

1 Warning
⚠️ This PR is assigned to the milestone 18.7. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@samiuelson samiuelson disabled auto-merge May 15, 2024 08:00
@samiuelson samiuelson marked this pull request as draft May 15, 2024 08:03
@samiuelson samiuelson marked this pull request as ready for review May 15, 2024 08:09
private val isWindowSizeExpandedAndBigger: IsWindowClassExpandedAndBigger,
) {
@Suppress("ReturnCount")
suspend operator fun invoke(): Boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another important thing to notice - we have to check the flag first, otherwise all these checks will be performed even on the production build making it slower for no reason at the moment

Copy link
Contributor

@kidinov kidinov May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even after we check FF first in here, we may still need to create a ticket to consider early background check + caching here. Currently, we do network requests, and the whole "more" screen doesn't show anything. Depending on the entry point we probably will need to reconsider the approach

Copy link
Contributor Author

@samiuelson samiuelson May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kidinov, good point! Do you think a naive in-memory cache like this is enough for now? –32a4e39

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samiuelson
it's not really needed because the state of the UI is cached in the ViewModel anyway, so it's kinda fetched once anyway, but that first time is looking bad. So you can keep it or revert - doesn't matter, but the most important that you moved isWooPosFFEnabled here so on the release builds we won't slow this down

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samiuelson Oh I see. The VM initiated even before the fragment is opened. Then the caching probably makes sense even for debug builds - we just need to keep in mind that the app will have to be killed in case of a site change. I'd add a ticket to come back to this closer to the release - we will need cache invalidation here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, now the menu more screen should load faster even the first time because the IsWooPosEnabled-related requests are now executed in the MainActivityViewModel::init – right after the user launches the app (or logs in) and the result is stored in the memory (IsWooPosEnabled is made a singleton).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool – I created the issue to test cache invalidation need later – #11520

Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samiuelson thank you for your work!

I left a few comments, and I believe some of them are important to address; please take a look

@samiuelson samiuelson requested a review from kidinov May 15, 2024 08:55
@@ -89,3 +89,7 @@ object UiHelpers {
class IsWindowClassLargeThanCompact @Inject constructor(val context: Context) {
operator fun invoke() = context.windowSizeClass != WindowSizeClass.Compact
}

class IsWindowClassExpandedAndBigger @Inject constructor(val context: Context) {
operator fun invoke() = context.windowSizeClass == WindowSizeClass.ExpandedAndBigger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if small tablets or big phones e.g. 7-8 inch will be covered by that? Do we actually plan to support 7-8inch size devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current condition targets an 8" or larger diagonal (assuming a standard 16:10 ratio). I added a ticket to discuss it and adjust final values later - #11522

@kidinov kidinov self-requested a review May 15, 2024 12:45
Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@samiuelson samiuelson enabled auto-merge May 15, 2024 12:57
@samiuelson samiuelson disabled auto-merge May 16, 2024 10:29
@samiuelson samiuelson enabled auto-merge May 16, 2024 11:29
@samiuelson samiuelson disabled auto-merge May 16, 2024 13:14
@samiuelson samiuelson marked this pull request as draft May 16, 2024 13:14
@codecov-commenter
Copy link

codecov-commenter commented May 16, 2024

Codecov Report

Attention: Patch coverage is 70.83333% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 40.46%. Comparing base (293506d) to head (cfa9d6b).
Report is 9 commits behind head on trunk.

❗ Current head cfa9d6b differs from pull request most recent head 535d184. Consider uploading reports for the commit 535d184 to get more accurate results

Files Patch % Lines
...m/woocommerce/android/ui/woopos/IsWooPosEnabled.kt 84.21% 0 Missing and 3 partials ⚠️
...woocommerce/android/ui/woopos/IsWooPosFFEnabled.kt 0.00% 2 Missing ⚠️
...n/kotlin/com/woocommerce/android/util/UiHelpers.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #11513      +/-   ##
============================================
+ Coverage     40.45%   40.46%   +0.01%     
- Complexity     5181     5191      +10     
============================================
  Files          1082     1083       +1     
  Lines         62904    62925      +21     
  Branches       8616     8626      +10     
============================================
+ Hits          25447    25463      +16     
- Misses        35169    35171       +2     
- Partials       2288     2291       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@samiuelson samiuelson marked this pull request as ready for review May 16, 2024 14:29
@samiuelson samiuelson requested a review from a team as a code owner May 16, 2024 14:29
@samiuelson samiuelson enabled auto-merge May 16, 2024 14:29
@samiuelson samiuelson merged commit 999a9cf into trunk May 16, 2024
15 checks passed
@samiuelson samiuelson deleted the 11498-woo-pos-build-a-class-that-determine-if-pos-mode-available-show-entry-point-only-if-it-allows-it branch May 16, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Woo POS] Build a class that determine if POS mode available. Show entry point only if it allows it
6 participants